<?php
Yii::import('Cms.components.widgets.BaseCmsWidget');

/**
* Display list of content items.
* It will render data using zii.widgets.CListView together 
* with the default _view of the item content type
*/
class GenericList extends BaseCmsWidget {
    
    
    public function run(){
        $layout = $this->SelectedLayout;
        $layout->data = array('dataProvider' => $this->getActiveDataProvider());
        return $layout->render();
    }    
    
    /**
    * This widget uses the same createUrl of the GenericView
    * 
    * @param mixed $params
    */
    public function getCreateUrl($params) {
//        $className = get_class($this);
        $route = '/'.$this->getModuleId().'/widgets/genericView/create';
        return url($route, $params);
    }
    
    ////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////               ////////////////////////////////////
    /////////////////////////////////   PARAMTERS   ////////////////////////////////////
    /////////////////////////////////               ////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////
    
    /**
    * Override this property to define parameter for the widget
    * 
    * @var array
    */
    protected $settingParams = array(
            'DetailUrl' => array(
                'type' => 'text',
                'htmlOptions' => array('size' => 60),
                'label' => 'Detail Url Format',
                'description' => '',
                'setting_group' => 'General Settings',
                'ordering' => 0,
                'visible' => 1
            ),
//            'name' => array(
//                'type' => CHtml::function or Yii path to a widget. 
                            //If CHtml function then the function name is in lower case. 
                            //Suffixes like 'field' or 'button' must be removed
//                'rules' => array('rule name - see Yii rule classes' => array(config)),
//                'items' => array(key => value) //used for dropDownList of similar CHtml functions
//                'htmlOptions' => array()
//                // following items are used to setup the widget setting info while installing  
//                'label'           => 'Short friendly param name'
//                'value'           => 'default value'
//                'description'     => 'Full description'
//                'setting_group'   => 'General Settings'
//                'ordering'        => 0
//                'visible'         => 0
//            ),
    );

}